package com.quickcode.example.atomic;

import com.quickcode.annotation.Safe;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicReference;

/**
 * Created by 张波 on 2019/10/22.
 */
@Slf4j
@Safe
public class ExampleAtomic4 {

    private static AtomicReference<Integer> count = new AtomicReference<>(0);

    public static void main(String[] args) {
        count.compareAndSet(0,2);
        count.compareAndSet(1,3);
        count.compareAndSet(2,4);
        count.compareAndSet(0,5);
        System.out.println(count.get());
    }

}
